package com.xique.door.service.impl;


import com.xique.common.core.text.Convert;
import com.xique.door.bean.domain.ElevatorFault;
import com.xique.door.bean.vo.elevator.ElevatorFaultCountStatisticVO;
import com.xique.door.bean.vo.elevator.ElevatorFaultVO;
import com.xique.door.mapper.ElevatorFaultMapper;
import com.xique.door.service.IElevatorFaultService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shd
 * @create 2021/10/14 9:06
 */
@Service
public class ElevatorFaultServiceImpl implements IElevatorFaultService
{
    @Autowired
    private ElevatorFaultMapper elevatorFaultMapper;

    /**
     * 查询故障集合
     *
     * @param id 故障集合ID
     * @return 故障集合
     */
    @Override
    public ElevatorFault selectElevatorFaultById(Long id)
    {
        return elevatorFaultMapper.selectElevatorFaultById(id);
    }

    @Override
    public ElevatorFault selectLastElevatorFaultByElvId(Long elvId) {
        return elevatorFaultMapper.selectLastElevatorFaultByElvId(elvId);
    }

    /**
     * 查询故障集合列表
     *
     * @param elevatorFault 故障集合
     * @return 故障集合
     */
    @Override
    public List<ElevatorFault> selectElevatorFaultList(ElevatorFault elevatorFault)
    {
        return elevatorFaultMapper.selectElevatorFaultList(elevatorFault);
    }

    @Override
    public List<ElevatorFaultVO> selectElevatorLastElectromobileFaultList() {
        return elevatorFaultMapper.selectElevatorLastElectromobileFaultList();
    }

    /**
     * 新增故障集合
     *
     * @param elevatorFault 故障集合
     * @return 结果
     */
    @Override
    public int insertElevatorFault(ElevatorFault elevatorFault)
    {
        return elevatorFaultMapper.insertElevatorFault(elevatorFault);
    }

    @Override
    public int insertElevatorFaults(List<ElevatorFault> list) {
        if (CollectionUtils.isEmpty(list)) {
            return 1;
        }
        return elevatorFaultMapper.insertElevatorFaults(list);
    }

    /**
     * 修改故障集合
     *
     * @param elevatorFault 故障集合
     * @return 结果
     */
    @Override
    public int updateElevatorFault(ElevatorFault elevatorFault)
    {
        return elevatorFaultMapper.updateElevatorFault(elevatorFault);
    }

    /**
     * 删除故障集合对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteElevatorFaultByIds(String ids)
    {
        return elevatorFaultMapper.deleteElevatorFaultByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除故障集合信息
     *
     * @param id 故障集合ID
     * @return 结果
     */
    @Override
    public int deleteElevatorFaultById(Long id)
    {
        return elevatorFaultMapper.deleteElevatorFaultById(id);
    }

    @Override
    public int selectElevatorFaultCountByElvIdInMonth(Long elvId) {
        return elevatorFaultMapper.selectElevatorFaultCountByElvIdInMonth(elvId);
    }

    @Override
    public List<ElevatorFaultCountStatisticVO> selectElevatorFaultCountsByElvIdsInMonth(List<Long> list) {
        if (CollectionUtils.isEmpty(list)) {
            return new ArrayList<>();
        }
        return elevatorFaultMapper.selectElevatorFaultCountsByElvIdsInMonth(list);
    }

    @Override
    public List<ElevatorFaultVO> selectElevatorFaultsByAddressCodeInMonth(Long code) {
        return elevatorFaultMapper.selectElevatorFaultsByAddressCodeInMonth(code);
    }

    @Override
    public List<ElevatorFaultVO> selectElevatorFaultsByParkIdInMonth(Long parkId) {
        return elevatorFaultMapper.selectElevatorFaultsByParkIdInMonth(parkId);
    }

    @Override
    public Long selectElevatorFaultTimesStatisticByAddressCode(Long code) {
        return elevatorFaultMapper.selectElevatorFaultTimesStatisticByAddressCode(code);
    }

    @Override
    public Integer selectElevatorFaultDeviceCountStatisticByAddressCode(Long code) {
        return elevatorFaultMapper.selectElevatorFaultDeviceCountStatisticByAddressCode(code);
    }

    @Override
    public List<Long> selectElevatorFaultDayStatisticByAddressCode(Long code) {
        return elevatorFaultMapper.selectElevatorFaultDayStatisticByAddressCode(code);
    }
}